home *** CD-ROM | disk | FTP | other *** search
- /* -----------------------------------------------------------------------------
-
- Scan handler looking for Pascal-style functions & procedure.
-
- Scan handlers are plain functions (loadSeg()'ed): no standard C startup
- code and no library calls permitted. We have to put string constants into
- the code segment (DICE compiler: option -ms1).
-
- DICE:
-
- dcc pascal.c -// -l0 -md -mRR -o golded:etc/scanner/pascal
-
- ------------------------------------------------------------------------------
- */
-
- #include <exec/types.h>
-
- #define UPPER(a) ((a) & 95)
-
- ULONG
- ScanHandlerPascal(__D0 ULONG len, __A0 char **text, __A1 ULONG *line)
- {
- const char *version = "$VER: Pascal 1.2 (" __COMMODORE_DATE__ ")";
-
- if (len > 9) {
-
- if (UPPER(**text) == 'F') {
-
- if ((UPPER((*text)[1]) == 'U') && (UPPER((*text)[2]) == 'N') && (UPPER((*text)[3]) == 'C') && (UPPER((*text)[4]) == 'T') && (UPPER((*text)[5]) == 'I') && (UPPER((*text)[6]) == 'O') && (UPPER((*text)[7]) == 'N') && ((*text)[8] == ' ')) {
-
- UBYTE *next;
-
- // found FUNCTION
-
- *text += 8;
- len -= 8;
-
- // ignore spaces before function name
-
- while (len && ((**text == ' ') || (**text == 9))) {
-
- ++*text;
- --len;
- }
-
- // extract function name
-
- for (next = *text; len--; ++next)
-
- if ((UPPER(*next) < 'A') || (UPPER(*next) > 'Z'))
-
- if ((*next < '0') || (*next > '9'))
-
- if (*next != '_')
-
- break;
-
- return(next - *text);
- }
- }
- else if (UPPER(**text) == 'P') {
-
- if ((UPPER((*text)[1]) == 'R') && (UPPER((*text)[2]) == 'O') && (UPPER((*text)[3]) == 'C') && (UPPER((*text)[4]) == 'E') && (UPPER((*text)[5]) == 'D') && (UPPER((*text)[6]) == 'U') && (UPPER((*text)[7]) == 'R') && (UPPER((*text)[8]) == 'E') && ((*text)[9] == ' ')) {
-
- UBYTE *next;
-
- // found PROCEDURE
-
- *text += 9;
- len -= 9;
-
- // ignore spaces before procedure name
-
- while (len && ((**text == ' ') || (**text == 9))) {
-
- ++*text;
- --len;
- }
-
- // extract procedure name
-
- for (next = *text; len--; ++next)
-
- if ((UPPER(*next) < 'A') || (UPPER(*next) > 'Z'))
-
- if ((*next < '0') || (*next > '9'))
-
- if (*next != '_')
-
- break;
-
- return(next - *text);
- }
- }
- }
-
- return(FALSE);
- }
-
-